home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / conf2 / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-09-14  |  7.3 KB

  1. Subject:  v16i004:  Multi-user conference system, Part04/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Keith Gabryelski <ucsd!elgar!ag>
  7. Posting-number: Volume 16, Issue 4
  8. Archive-name: conf/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create the files:
  15. #    confsig.c
  16. #    confstr.c
  17. #    extern.h
  18. #    structs.h
  19. export PATH; PATH=/bin:$PATH
  20. if test -f 'confsig.c'
  21. then
  22.     echo shar: will not over-write existing file "'confsig.c'"
  23. else
  24. cat << \SHAR_EOF > 'confsig.c'
  25. #include "conf.h"
  26.  
  27. int nsig = 16;
  28.  
  29. char *sig_list[] =
  30. {
  31.     "Unkown Signal: 0",
  32.     "Hangup",
  33.     "Interrupt",
  34.     "Quit",
  35.     "Illegal Instruction",
  36.     "Trace Trap", 
  37.     "IOT Instruction",
  38.     "EMT Instruction",
  39.     "Floating Point Exception",
  40.     "Kill",
  41.     "Bus Error",
  42.     "Segmentation Violation",
  43.     "Bad Argument To System Call",
  44.     "Write On A Pipe With No One To Read It",
  45.     "Alarm Clock",
  46.     "Software Termination Signal From Kill",
  47. };
  48.  
  49. fatal(sig)
  50. int sig;
  51. {
  52.     int p;
  53.  
  54.     (void) printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
  55.     make_nice(FALSE);
  56.  
  57.     p = kill(cuser.cu_procid, sig);
  58.     if (p < 0)
  59.     (void) fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
  60.                progname, cuser.cu_procid, puterr(errno));
  61.  
  62.     (void) exit(-1);
  63. }
  64.  
  65. char *
  66. putsig(sig)
  67. int sig;
  68. {
  69.     static char qwerty[42];
  70.  
  71.     (void) sprintf(qwerty, "Unknown Signal: %d", sig);
  72.  
  73.     return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
  74. }
  75. SHAR_EOF
  76. fi # end of overwriting check
  77. if test -f 'confstr.c'
  78. then
  79.     echo shar: will not over-write existing file "'confstr.c'"
  80. else
  81. cat << \SHAR_EOF > 'confstr.c'
  82. #include "conf.h"
  83.  
  84. unsigned int wordlen;
  85.  
  86. char *
  87. parsestr(string, length, flags)
  88. char *string;
  89. int length, flags;
  90. {
  91.     static char *retbuf;
  92.     static int buflen = 0;
  93.     static char *prevs;
  94.     static int prevl;
  95.     char *p;
  96.  
  97.     if (buflen == 0)
  98.     retbuf = mymalloc((unsigned)(buflen = PAGESIZ));
  99.  
  100.     p = retbuf;
  101.  
  102.     if (!length)
  103.     {
  104.     string = prevs;
  105.     length = prevl;
  106.     }
  107.  
  108.     while (length && isspace(*string))
  109.     {
  110.         ++string;
  111.     --length;
  112.     }
  113.  
  114.     prevs = string;
  115.     prevl = length;
  116.  
  117.     if (!length)
  118.     {
  119.     wordlen = linelen = 0;
  120.     return NULL;
  121.     }
  122.  
  123.     while (length &&
  124.        ((flags&THEREST) || (!isspace(*string) &&
  125.                 (*string != ',') && (*string != '='))))
  126.     {
  127.     if (*string == '"')
  128.     {
  129.         ++string;  --length;
  130.  
  131.         while (length && (*string != '"'))
  132.         {
  133.         if (*string == '\\')
  134.         {
  135.             ++string; --length;
  136.  
  137.             if (length && isdigit(*string))
  138.             {
  139.             int x, c;
  140.  
  141.             x = (*string++ - '0');  --length;
  142.  
  143.             if (length && isdigit(*string))
  144.             {
  145.                 x = (x * 10) + (*string++ - '0');  --length;
  146.  
  147.                 if (length && isdigit(*string))
  148.                 {
  149.                 c = (x * 10) + (*string - '0');
  150.                 if (c < 256)
  151.                 {
  152.                     x = c;
  153.                     ++string;  --length;
  154.                 }
  155.                 }
  156.             }
  157.  
  158.             *p++ = x;
  159.             }
  160.             else
  161.             if (length)
  162.             {
  163.                 *p++ = *string++;  --length;
  164.             }
  165.         }
  166.         else
  167.         {
  168.             *p++ = *string++; --length;
  169.         }
  170.         }
  171.     }
  172.     else
  173.     {
  174.         if (*string == '\\')
  175.         {
  176.         ++string; --length;
  177.  
  178.         if (length && isdigit(*string))
  179.         {
  180.             int x, c;
  181.  
  182.             x = (*string++ - '0');  --length;
  183.  
  184.             if (length && isdigit(*string))
  185.             {
  186.             x = (x * 10) + (*string++ - '0');  --length;
  187.  
  188.             if (length && isdigit(*string))
  189.             {
  190.                 c = (x * 10) + (*string - '0');
  191.                 if (c < 256)
  192.                 {
  193.                 x = c;
  194.                 ++string;  --length;
  195.                 }
  196.             }
  197.             }
  198.  
  199.             *p++ = x;
  200.         }
  201.         else
  202.             if (length)
  203.             {
  204.             *p++ = *string++;  --length;
  205.             }
  206.         }
  207.         else
  208.         {
  209.         *p++ = *string++; --length;
  210.         }
  211.     }
  212.     }
  213.  
  214.     *p = '\0';
  215.  
  216.     while (length && isspace(*string))
  217.     {
  218.         ++string;  --length;
  219.     }
  220.  
  221.     if (length && ((*string == ',') || (*string == '=')))
  222.     {
  223.     ++string;  --length;
  224.     } 
  225.  
  226.     prevs = string;
  227.     prevl = length;
  228.  
  229.     linelen = length;
  230.     wordlen = p - retbuf;
  231.  
  232.     return wordlen ? retbuf : NULL;
  233. }
  234.  
  235. cpystr(to, from, length)
  236. register char *to, *from;
  237. register unsigned int length;
  238. {
  239.    while(length--) *to++ = *from++;
  240. }
  241.  
  242. char *
  243. puterr(error)
  244. int error;
  245. {
  246.     static char qwerty[42];
  247.  
  248.     (void) sprintf(qwerty, "Unknown error %d", error);
  249.  
  250.     return ((unsigned)error >= sys_nerr) ? qwerty : sys_errlist[error];
  251. }
  252. SHAR_EOF
  253. fi # end of overwriting check
  254. if test -f 'extern.h'
  255. then
  256.     echo shar: will not over-write existing file "'extern.h'"
  257. else
  258. cat << \SHAR_EOF > 'extern.h'
  259. extern errno;
  260.  
  261. extern struct passwd *getpwuid();
  262.  
  263. extern FILE *fopen(), *popen();
  264. extern char *getlogin(), *malloc(), *realloc(), *strchr(), *strrchr();
  265. extern char *ttyname(), *getenv(), *strcpy(), *strncpy(), *strcat();
  266.  
  267. extern char *tgetstr();
  268. extern void tputs();
  269.  
  270. extern char *sys_errlist[];
  271. extern int sys_nerr;
  272. extern long lseek();
  273. extern void free(), longjmp();
  274. extern unsigned alarm(), sleep();
  275.  
  276. extern char *progname;
  277. extern int log_rfd, log_wfd, usr_fd;
  278. extern long ourplace;
  279. extern FILE *rec_fp;
  280. extern int confing, columns, lines;
  281. extern char ichar, qchar;
  282.  
  283. extern char *wrdata, replytty[], replyname[];
  284. extern unsigned wdlen;
  285.  
  286. extern struct cusrfil cuser, tuser;
  287. extern struct clogfil clog, tlog;
  288.  
  289. extern int banner, seeme, informe, lineinput, beep;
  290. extern int expand8bit, expandctrl;
  291. extern unsigned linelen, wordlen;
  292.  
  293. extern int nice_exit(), write_log();
  294. extern int version(), do_to(), messptr(), colprnt(), fatal();
  295. extern int getopts(), getrc(), setopts(), dispchar(), do_ring();
  296. extern char *logname, *homedir;
  297. extern char *pager, *shell, *normform, *lineform, *shoutform, *sendform;
  298. extern char *informform, *recfile;
  299.  
  300. extern char *cls;
  301.  
  302. #ifdef    SYSV
  303. extern struct termio term, saveterm;
  304. #endif    SYSV
  305.  
  306. #ifdef    BSD
  307. extern struct tchars chrstr;
  308. extern struct sgttyb ktty;
  309. extern int ttyflags;
  310. #endif    BSD
  311.  
  312. extern char *getline(), *mymalloc(), *myrealloc(), *puterr();
  313. extern char *getword(), *parsestr(), *putsig();
  314. SHAR_EOF
  315. fi # end of overwriting check
  316. if test -f 'structs.h'
  317. then
  318.     echo shar: will not over-write existing file "'structs.h'"
  319. else
  320. cat << \SHAR_EOF > 'structs.h'
  321. /*
  322.  * logfile (CONFLOG) struct 
  323.  *
  324.  */
  325.  
  326. struct clogfil
  327. {
  328.     int type;
  329.     int f_line;
  330.     unsigned int f_usrlen;
  331.     unsigned int f_ttylen;
  332.     unsigned int t_utlen;
  333.     unsigned int messlen;
  334. };
  335.  
  336. /*
  337.  * message type
  338.  *
  339.  */
  340.  
  341. #define    NORMAL        0
  342. #define    SEND        1
  343. #define    SHOUT        2
  344. #define    INFORM        3
  345.  
  346. /*
  347.  * userfile (CONFUSERS) struct
  348.  *
  349.  */
  350.  
  351. struct cusrfil
  352. {
  353.     int cu_flags;
  354.     char cu_cname[MAXNAMELEN];
  355.     char cu_tty[MAXTTYLEN];
  356.     int cu_line;
  357.     short cu_procid;
  358. };
  359.  
  360. /*
  361.  * cu_flags
  362.  *
  363.  */
  364.  
  365. #define    USER_OFF    0
  366. #define    USER_ON        1
  367. #define    USER_RECORD    2
  368.  
  369. /*
  370.  * Structure of valid options
  371.  *
  372.  */
  373.  
  374. struct varopts
  375.     {
  376.     char *name;
  377.     int type;
  378.     int *var;
  379.     int extra;
  380.     int (*var_func)();
  381.     };
  382.  
  383. /*
  384.  * Some flags to go with varopt struct
  385.  *
  386.  */
  387.  
  388. #define    BOOLEAN        0
  389. #define    NUMBER        1
  390. #define    STRING        2
  391. #define    VARMASK        3
  392.  
  393. #define    DISPLAY        0
  394. #define    NODISPLAY    4
  395. #define    DISPLAYMASK    4
  396.  
  397. #define    POINTER        1
  398. #define    ROUTINE        2
  399.  
  400. /*
  401.  * Return values from setops
  402.  *
  403.  */
  404.  
  405. #define    NOOPT        0
  406. #define    FOUNDOPT    1
  407. #define    AMBIGUOUS    2
  408.  
  409. /*
  410.  * for the who routine
  411.  *
  412.  */
  413.  
  414. struct whostr
  415.     {
  416.     char name[MAXNAMELEN+1];
  417.     char tty[MAXTTYLEN+1];
  418.     int line;
  419.     int flags;
  420.     };
  421. SHAR_EOF
  422. fi # end of overwriting check
  423. #    End of shell archive
  424. exit 0
  425. -- 
  426.   "If green is all there is to be, then green is good enough for me" - ktf
  427. [  Keith   ]  UUCP: {ucsd, cbosgd!crash, sdcsvax!crash, nosc!crash}!elgar!ag
  428. [Gabryelski]  INET: ag@elgar.cts.com                 ARPA: elgar!ag@ucsd.edu
  429.  
  430.